package cn.boysoft.module.security.model.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.annotation.JsonIgnore;

import cn.boysoft.core.annotation.JEEEntityDeclare;
import cn.boysoft.core.model.entity.BaseEntity;
/**
 * 
 * @author 付厚俊
 * CreateTime 2013-4-4 下午5:09:32
 */
@Table(name="jee_user")
@Entity
@JEEEntityDeclare(name="用户信息")
public class UserEntity extends BaseEntity {
	@Column(length=36,nullable=false)
	private String userName;
	@Column(length=64)
	private String password;
	@Column(length=36)
	private String realName;
	@Type(type="yes_no")
	private Boolean enabled = true;
	@ManyToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
    @JoinTable(name = "jee_user_role", joinColumns = {
    @JoinColumn(name = "userId")}, inverseJoinColumns = {
    @JoinColumn(name = "roleId")})
    @JsonIgnore
	Set<RoleEntity> roles;
	@ManyToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
    @JoinTable(name = "jee_user_post", joinColumns = {
    @JoinColumn(name = "userId")}, inverseJoinColumns = {
    @JoinColumn(name = "postId")})
    @JsonIgnore
	Set<PostEntity> posts;
	
	@ManyToOne
	@JoinColumn(name="orgId")
	private OrgEntity org;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public Boolean getEnabled() {
		return enabled;
	}
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
	public Set<RoleEntity> getRoles() {
		return roles;
	}
	public void setRoles(Set<RoleEntity> roles) {
		this.roles = roles;
	}
	public Set<PostEntity> getPosts() {
		return posts;
	}
	public void setPosts(Set<PostEntity> posts) {
		this.posts = posts;
	}
	public OrgEntity getOrg() {
		return org;
	}
	public void setOrg(OrgEntity org) {
		this.org = org;
	}
	
	
}
